package com.kucai.yifaqapp.ui.fragment;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.SystemClock;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.util.Log;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.kucai.yifaqapp.R;
import com.kucai.yifaqapp.global.HttpAdress;
import com.kucai.yifaqapp.global.Info;
import com.kucai.yifaqapp.model.CustomObserver;
import com.kucai.yifaqapp.model.network.HttpJsonUtils;
import com.kucai.yifaqapp.model.network.entity.res.ResLottery1;
import com.kucai.yifaqapp.ui.activity.LotteryopenActivity;
import com.kucai.yifaqapp.util.Liuhecaibose;
import com.kucai.yifaqapp.util.OnItemClickListener;
import com.kucai.yifaqapp.util.TimeTools;
import com.kucai.yifaqapp.util.Timeutils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import butterknife.BindView;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

public class LauncherViewPagerResultFragment1 extends BaseFragmentSimple {
    @BindView(R.id.reault_rl)
    RecyclerView reaultRl;
    @BindView(R.id.skinbg)
    LinearLayout skinbg;
    private MyAdapter adapter;
    //    private List<TimerItem> mDatas;
    private Context mContext;
    //用于退出 Activity,避免 Countdown，造成资源浪费。
    private ArrayList<ResLottery1.DataBean> lotterydata = new ArrayList<>();//开奖结果
    private Map<String, String> map = new HashMap<String, String>();//开奖结果
    //赛车 跑马   快艇
    int[] img = {R.mipmap.one, R.mipmap.two, R.mipmap.three, R.mipmap.four, R.mipmap.fiv, R.mipmap.six, R.mipmap.seven,
            R.mipmap.eight, R.mipmap.noon, R.mipmap.ten};
    //时时彩
    int[] img1 = {R.mipmap.ones, R.mipmap.twos, R.mipmap.threes, R.mipmap.fours, R.mipmap.fivs, R.mipmap.sixs, R.mipmap.sevens,
            R.mipmap.eights, R.mipmap.noons, R.mipmap.tens};
    //niuniu
    int[] img2 = {R.mipmap.niu0, R.mipmap.niu1, R.mipmap.niu2, R.mipmap.niu3, R.mipmap.niu4, R.mipmap.niu5, R.mipmap.niu6,
            R.mipmap.niu7, R.mipmap.niu8, R.mipmap.niu9, R.mipmap.niu10,};
    //筛子
    int[] blankiv = {R.mipmap.sieve_r1, R.mipmap.sieve_b2, R.mipmap.sieve_b3, R.mipmap.sieve_r4, R.mipmap.sieve_b5, R.mipmap.sieve_b6};

    //六合彩

    int[] qiu = {R.mipmap.hongqiu, R.mipmap.lanqiu, R.mipmap.lvqiu};

    @Override
    protected int setContentView() {
        return R.layout.fragment_result;
    }

    @Override
    protected void ChangeSkin() {
        switch (SkinId) {
            case 17771:
                skinbg.setBackgroundResource(R.mipmap.skin_bg1);
                break;
            case 17772:
                skinbg.setBackgroundResource(R.mipmap.skin_bg2);
                break;
            case 17773:
                skinbg.setBackgroundResource(R.mipmap.skin_bg3);
                break;
            default:
                skinbg.setBackgroundResource(R.mipmap.skin_bg1);
        }
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        if (Info.user != null) {
            if (Info.user.token != null) {
                getlottery(false, 0);
            }
        }
        InitView();
    }

    //这个界面必选刷新
    @Override
    public void onHiddenChanged(boolean hidden) {
        super.onHiddenChanged(hidden);
        if (!hidden) {
            if (Info.user != null) {
                if (Info.user.token != null) {
                    getlottery(false, 0);
                }
            }
        } else {
            adapter.cancelAllTimers();
        }
    }

    private void InitView() {
        //活动列表view
        //添加布局管理器
        reaultRl.setLayoutManager(new LinearLayoutManager(getContext()));
        //创建适配器
        adapter = new MyAdapter();
        reaultRl.setAdapter(adapter);
    }

    private void InitData() {

    }


    /////////////////////////////////////////////////////////////////////////////////////////////////
    class MyAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
            implements OnItemClickListener {
        private SparseArray<CountDownTimer> countDownMap = new SparseArray<>();
        private long mtemptime;

        public void setGetTime(long temptime) {
            this.mtemptime = temptime;
        }

        /**
         * 清空资源
         */
        public void cancelAllTimers() {
            if (countDownMap == null) {
                return;
            }
            Log.e("TAG", "size :  " + countDownMap.size());
            for (int i = 0, length = countDownMap.size(); i < length; i++) {
                CountDownTimer cdt = countDownMap.get(countDownMap.keyAt(i));
                if (cdt != null) {
                    cdt.cancel();
                }
            }
        }

        @Override
        public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            switch (viewType) {
                case 1:
                    return new MViewHolder(LayoutInflater.from(getActivity())
                            .inflate(R.layout.result_item1, parent, false));
                case 2:
                    return new MViewHolder1(LayoutInflater.from(getActivity())
                            .inflate(R.layout.result_item1, parent, false));
                case 3:
                    return new MViewHolder2(LayoutInflater.from(getActivity())
                            .inflate(R.layout.result_item2, parent, false));
                case 4:
                    return new MViewHolder3(LayoutInflater.from(getActivity())
                            .inflate(R.layout.result_item3, parent, false));
                case 5:
                    return new MViewHolder4(LayoutInflater.from(getActivity())
                            .inflate(R.layout.result_item5, parent, false));
                case 6:
                    return new MViewHolder5(LayoutInflater.from(getActivity())
                            .inflate(R.layout.result_item4, parent, false));
                case 7:
                    return new MViewHolder6(LayoutInflater.from(getActivity())
                            .inflate(R.layout.result_item5, parent, false));
                case 8:
                    return new MViewHolder7(LayoutInflater.from(getActivity())
                            .inflate(R.layout.result_item5, parent, false));
                case 9:
                    return new MViewHolder8(LayoutInflater.from(getActivity())
                            .inflate(R.layout.result_item5, parent, false));
                case 10:
                    return new MViewHolder9(LayoutInflater.from(getActivity())
                            .inflate(R.layout.result_item6, parent, false));
            }
            return null;
        }

        @Override
        public int getItemViewType(int position) {
            //赛车
            if (lotterydata.get(position).gameId == 80
                    || lotterydata.get(position).gameId == 50
                    || lotterydata.get(position).gameId == 82
                    || lotterydata.get(position).gameId == 99
                    || lotterydata.get(position).gameId == 55
                    || lotterydata.get(position).gameId == 801
                    || lotterydata.get(position).gameId == 804
                    || lotterydata.get(position).gameId == 901
                    || lotterydata.get(position).gameId == 802) {
                return 1;
                //时时彩112    113分分彩
            } else if (lotterydata.get(position).gameId == 1
                    || lotterydata.get(position).gameId == 112
                    || lotterydata.get(position).gameId == 113
                    || lotterydata.get(position).gameId == 4
                    || lotterydata.get(position).gameId == 803
                    || lotterydata.get(position).gameId == 902
                    || lotterydata.get(position).gameId == 81) {
                return 2;
                //牛牛
            } else if (lotterydata.get(position).gameId == 91
                    || lotterydata.get(position).gameId == 90) {
                return 3;
                //pc蛋蛋
            } else if (lotterydata.get(position).gameId == 66) {
                return 4;
                //快乐北京8
            } else if (lotterydata.get(position).gameId == 65) {
                return 5;
                //快三
            } else if (lotterydata.get(position).gameId == 86
                    || lotterydata.get(position).gameId == 10
                    || lotterydata.get(position).gameId == 12
                    || lotterydata.get(position).gameId == 13
                    || lotterydata.get(position).gameId == 16
                    || lotterydata.get(position).gameId == 15
                    || lotterydata.get(position).gameId == 18
                    || lotterydata.get(position).gameId == 11) {
                return 6;
                //北京快乐十分
            } else if (lotterydata.get(position).gameId == 60) {
                return 7;
                //幸运农场
            } else if (lotterydata.get(position).gameId == 61) {
                return 8;
                //十一选五
            } else if (lotterydata.get(position).gameId == 21) {
                return 9;
                //六合彩
            } else if (lotterydata.get(position).gameId == 70
                    || lotterydata.get(position).gameId == 85
                    || lotterydata.get(position).gameId == 903
                    || lotterydata.get(position).gameId == 904) {
                return 10;
            } else {
                return 0;
            }

        }

        @Override
        public void onBindViewHolder(final RecyclerView.ViewHolder viewHolder, final int position) {
            if (viewHolder instanceof MViewHolder) {
                MViewHolder holder = (MViewHolder) viewHolder;
                holder.resultname.setText(lotterydata.get(position).game_name + "");
                holder.resultdata.setText(lotterydata.get(position).preIssue + "期数");
                holder.resulttime.setText("");
                String[] strarray = new String[0];
                if (!TextUtils.isEmpty(lotterydata.get(position).preNum)) {
                    strarray = lotterydata.get(position).preNum.split(",");
                }
                if (strarray.length != 0) {
                    holder.includ1_one.setImageResource((img[Integer.parseInt(strarray[0]) - 1]));
                    holder.includ1_two.setImageResource((img[Integer.parseInt(strarray[1]) - 1]));
                    holder.includ1_three.setImageResource((img[Integer.parseInt(strarray[2]) - 1]));
                    holder.includ1_four.setImageResource((img[Integer.parseInt(strarray[3]) - 1]));
                    holder.includ1_five.setImageResource((img[Integer.parseInt(strarray[4]) - 1]));
                    holder.includ1_six.setImageResource((img[Integer.parseInt(strarray[5]) - 1]));
                    holder.includ1_seven.setImageResource((img[Integer.parseInt(strarray[6]) - 1]));
                    holder.includ1_eight.setImageResource((img[Integer.parseInt(strarray[7]) - 1]));
                    holder.includ1_noon.setImageResource((img[Integer.parseInt(strarray[8]) - 1]));
                    holder.includ1_ten.setImageResource((img[Integer.parseInt(strarray[9]) - 1]));
                    holder.ivtext_1.setText(Integer.parseInt(strarray[0]) + Integer.parseInt(strarray[1]) + ""); // 1
                    int a = Integer.parseInt(strarray[0]) + Integer.parseInt(strarray[1]);
                    if (a > 11) {
                        holder.ivtext_2.setText("大");
                    } else {
                        holder.ivtext_2.setText("小");
                    }
                    if (a % 2 == 0) {
                        holder.ivtext_3.setText("双");
                    } else {
                        holder.ivtext_3.setText("单");
                    }
                    holder.ivtext_4.setText(Integer.parseInt(strarray[0]) > Integer.parseInt(strarray[9]) ? "龙" : "虎"); // 4
                    holder.ivtext_5.setText(Integer.parseInt(strarray[1]) > Integer.parseInt(strarray[8]) ? "龙" : "虎"); // 5
                    holder.ivtext_6.setText(Integer.parseInt(strarray[2]) > Integer.parseInt(strarray[7]) ? "龙" : "虎"); // 6
                    holder.ivtext_7.setText(Integer.parseInt(strarray[3]) > Integer.parseInt(strarray[6]) ? "龙" : "虎"); // 7
                    holder.ivtext_8.setText(Integer.parseInt(strarray[4]) > Integer.parseInt(strarray[5]) ? "龙" : "虎"); // 8
                }
                try {
                    long time = Timeutils.getStringToDate(lotterydata.get(position).lotteryTime) - Timeutils.getStringToDate(lotterydata.get(position).serverTime);
                    long timeStamp = System.currentTimeMillis() - mtemptime;
                    long finaltime = time - timeStamp;

//            将前一个缓存清除
                    if (holder.countDownTimer != null) {
                        holder.countDownTimer.cancel();
                    }
                    if (time > 0) {
                        holder.countDownTimer = new CountDownTimer(finaltime + 500, 1000) {
                            public void onTick(long millisUntilFinished) {
                                holder.resulttime.setText(String.valueOf(TimeTools.getCountTimeByLong(millisUntilFinished)));
                                if (String.valueOf(TimeTools.getCountTimeByLong(millisUntilFinished)).equals("00:00:00")) {
                                    holder.resulttime.setText("开奖中");
                                }
                            }

                            public void onFinish() {
                                holder.resulttime.setText("开奖中");
                                getlottery(true, position);
//                        holder.resulttime.setText(lotterydata.get(position).game_name + ":结束");
                            }
                        }.start();
                        countDownMap.put(holder.resulttime.hashCode(), holder.countDownTimer);
                    } else {
//                holder.resulttime.setText("00:00:00");
//                holder.resulttime.setText(lotterydata.get(position).game_name + ":结束");
                        getlottery(true, position);
                    }
                } catch (Exception e) {

                }
                holder.itemView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent intent = new Intent(getContext(), LotteryopenActivity.class);
                        intent.putExtra("gameid", lotterydata.get(position).gameId + "");
                        intent.putExtra("gamename", lotterydata.get(position).game_name);
                        startActivity(intent);
                    }
                });

            } else if (viewHolder instanceof MViewHolder1) {
                MViewHolder1 holder = (MViewHolder1) viewHolder;
                holder.resultname.setText(lotterydata.get(position).game_name + "");
                holder.resultdata.setText(lotterydata.get(position).preIssue + "期数");
                holder.resulttime.setText("");
                String[] strarray = new String[0];
                if (!TextUtils.isEmpty(lotterydata.get(position).preNum)) {
                    strarray = lotterydata.get(position).preNum.split(",");
                }
                holder.includ1_six.setVisibility(View.GONE);
                holder.includ1_seven.setVisibility(View.GONE);
                holder.includ1_eight.setVisibility(View.GONE);
                holder.includ1_noon.setVisibility(View.GONE);
                holder.includ1_ten.setVisibility(View.GONE);
                holder.ivtext_5.setVisibility(View.GONE);
                holder.ivtext_6.setVisibility(View.GONE);
                holder.ivtext_7.setVisibility(View.GONE);
                holder.ivtext_8.setVisibility(View.GONE);
                if (strarray.length != 0) {
                    if (Integer.parseInt(strarray[0]) != 0) {
                        holder.includ1_one.setImageResource((img1[Integer.parseInt(strarray[0]) - 1]));
                    } else {
                        holder.includ1_one.setImageResource((img1[9]));
                    }
                    if (Integer.parseInt(strarray[1]) != 0) {
                        holder.includ1_two.setImageResource((img1[Integer.parseInt(strarray[1]) - 1]));
                    } else {
                        holder.includ1_two.setImageResource((img1[9]));
                    }
                    if (Integer.parseInt(strarray[2]) != 0) {
                        holder.includ1_three.setImageResource((img1[Integer.parseInt(strarray[2]) - 1]));
                    } else {
                        holder.includ1_three.setImageResource((img1[9]));
                    }
                    if (Integer.parseInt(strarray[3]) != 0) {
                        holder.includ1_four.setImageResource((img1[Integer.parseInt(strarray[3]) - 1]));
                    } else {
                        holder.includ1_four.setImageResource((img1[9]));
                    }
                    if (Integer.parseInt(strarray[4]) != 0) {
                        holder.includ1_five.setImageResource((img1[Integer.parseInt(strarray[4]) - 1]));
                    } else {
                        holder.includ1_five.setImageResource((img1[9]));
                    }
                    holder.ivtext_1.setText(Integer.parseInt(strarray[0]) + Integer.parseInt(strarray[1]) +
                            Integer.parseInt(strarray[2]) + Integer.parseInt(strarray[3]) + Integer.parseInt(strarray[4]) + ""); // 1
                    int a2 = Integer.parseInt(strarray[0]) + Integer.parseInt(strarray[1])
                            + (Integer.parseInt(strarray[2]) + Integer.parseInt(strarray[3]) + Integer.parseInt(strarray[4]));
                    if (a2 >= 23) {
                        holder.ivtext_2.setText("大");
                    } else {
                        holder.ivtext_2.setText("小");
                    }
                    if (a2 % 2 == 0) {
                        holder.ivtext_3.setText("双");
                    } else {
                        holder.ivtext_3.setText("单");

                    }
                    if (Integer.parseInt(strarray[0]) > Integer.parseInt(strarray[4])) {
                        holder.ivtext_4.setText("龙");
                    } else if (Integer.parseInt(strarray[0]) < Integer.parseInt(strarray[4])) {
                        holder.ivtext_4.setText("虎");
                    } else {
                        holder.ivtext_4.setText("和");
                    }
                }
                try {
                    long time = Timeutils.getStringToDate(lotterydata.get(position).lotteryTime) - Timeutils.getStringToDate(lotterydata.get(position).serverTime);
                    long timeStamp = System.currentTimeMillis() - mtemptime;
                    long finaltime = time - timeStamp;

//            将前一个缓存清除
                    if (holder.countDownTimer != null) {
                        holder.countDownTimer.cancel();
                    }
                    if (time > 0) {
                        holder.countDownTimer = new CountDownTimer(finaltime + 500, 1000) {
                            public void onTick(long millisUntilFinished) {
                                holder.resulttime.setText(String.valueOf(TimeTools.getCountTimeByLong(millisUntilFinished)));
                                if (String.valueOf(TimeTools.getCountTimeByLong(millisUntilFinished)).equals("00:00:00")) {
                                    holder.resulttime.setText("开奖中");
                                }
                            }

                            public void onFinish() {
                                holder.resulttime.setText("开奖中");
                                getlottery(true, position);
//                        holder.resulttime.setText(lotterydata.get(position).game_name + ":结束");
                            }
                        }.start();
                        countDownMap.put(holder.resulttime.hashCode(), holder.countDownTimer);
                    } else {
//                holder.resulttime.setText("00:00:00");
//                holder.resulttime.setText(lotterydata.get(position).game_name + ":结束");
                        getlottery(true, position);
                    }
                } catch (Exception e) {

                }
                holder.itemView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent intent = new Intent(getContext(), LotteryopenActivity.class);
                        intent.putExtra("gameid", lotterydata.get(position).gameId + "");
                        intent.putExtra("gamename", lotterydata.get(position).game_name);
                        startActivity(intent);
                    }
                });
            } else if (viewHolder instanceof MViewHolder2) {
                MViewHolder2 holder = (MViewHolder2) viewHolder;
                holder.resultname.setText(lotterydata.get(position).game_name + "");
                holder.resultdata.setText(lotterydata.get(position).preIssue + "期数");
                holder.resulttime.setText("");
                String[] strarray = new String[0];
                if (!TextUtils.isEmpty(lotterydata.get(position).preNum)) {
                    strarray = lotterydata.get(position).preNum.split(",");
                }
                if (strarray.length != 0) {
                    holder.kuai8_onet.setText(strarray[0]);
                    holder.kuai8_twot.setText(strarray[1]);
                    holder.kuai8_threet.setText(strarray[2]);
                    holder.kuai8_fourt.setText(strarray[3]);
                    holder.kuai8_fivt.setText(strarray[4]);
                    holder.kuai8_sixt.setText(strarray[5]);
                    holder.kuai8_sevent.setText(strarray[6]);
                    holder.kuai8_eightt.setText(strarray[7]);
                    holder.kuai8_noont.setText(strarray[8]);
                    holder.kuai8_tent.setText(strarray[9]);
                    if (-1 != lotterydata.get(position).n11) {
                        holder.niu1.setImageResource((img2[lotterydata.get(position).n11]));
                    } else {
                        holder.niu1.setImageResource((img2[0]));
                    }
                    if (-1 != lotterydata.get(position).n12) {
                        holder.niu2.setImageResource((img2[lotterydata.get(position).n12]));
                    } else {
                        holder.niu2.setImageResource((img2[0]));
                    }
                    if (-1 != lotterydata.get(position).n13) {
                        holder.niu3.setImageResource((img2[lotterydata.get(position).n13]));
                    } else {
                        holder.niu2.setImageResource((img2[0]));
                    }
                    if (-1 != lotterydata.get(position).n14) {
                        holder.niu4.setImageResource((img2[lotterydata.get(position).n14]));
                    } else {
                        holder.niu4.setImageResource((img2[0]));
                    }
                    if (-1 != lotterydata.get(position).n15) {
                        holder.niu5.setImageResource((img2[lotterydata.get(position).n15]));
                    } else {
                        holder.niu5.setImageResource((img2[0]));
                    }
                    if (-1 != lotterydata.get(position).n16) {
                        holder.niu6.setImageResource((img2[lotterydata.get(position).n16]));
                    } else {
                        holder.niu6.setImageResource((img2[0]));
                    }
                    if (lotterydata.get(position).winPlayer1 == 1) {
                        holder.xian1.setBackgroundColor(getContext().getResources().getColor(R.color.yellow));
                    }
                    if (lotterydata.get(position).winPlayer2 == 1) {
                        holder.xian2.setBackgroundColor(getContext().getResources().getColor(R.color.yellow));
                    }
                    if (lotterydata.get(position).winPlayer3 == 1) {
                        holder.xian3.setBackgroundColor(getContext().getResources().getColor(R.color.yellow));
                    }
                    if (lotterydata.get(position).winPlayer4 == 1) {
                        holder.xian4.setBackgroundColor(getContext().getResources().getColor(R.color.yellow));
                    }
                    if (lotterydata.get(position).winPlayer5 == 1) {
                        holder.xian5.setBackgroundColor(getContext().getResources().getColor(R.color.yellow));
                    }
                    if (lotterydata.get(position).winPlayer5 == 0 && lotterydata.get(position).winPlayer4 == 0
                            && lotterydata.get(position).winPlayer3 == 0 && lotterydata.get(position).winPlayer2 == 0
                            && lotterydata.get(position).winPlayer1 == 0) {
                        holder.zhuanglin.setBackgroundColor(getContext().getResources().getColor(R.color.yellow));
                    }
                }
                try {
                    long time = Timeutils.getStringToDate(lotterydata.get(position).lotteryTime) - Timeutils.getStringToDate(lotterydata.get(position).serverTime);
                    long timeStamp = System.currentTimeMillis() - mtemptime;
                    long finaltime = time - timeStamp;

//            将前一个缓存清除
                    if (holder.countDownTimer != null) {
                        holder.countDownTimer.cancel();
                    }
                    if (time > 0) {
                        holder.countDownTimer = new CountDownTimer(finaltime + 500, 1000) {
                            public void onTick(long millisUntilFinished) {
                                holder.resulttime.setText(String.valueOf(TimeTools.getCountTimeByLong(millisUntilFinished)));
                                if (String.valueOf(TimeTools.getCountTimeByLong(millisUntilFinished)).equals("00:00:00")) {
                                    holder.resulttime.setText("开奖中");
                                }
                            }

                            public void onFinish() {
                                holder.resulttime.setText("开奖中");
                                getlottery(true, position);
//                        holder.resulttime.setText(lotterydata.get(position).game_name + ":结束");
                            }
                        }.start();
                        countDownMap.put(holder.resulttime.hashCode(), holder.countDownTimer);
                    } else {
//                holder.resulttime.setText("00:00:00");
//                holder.resulttime.setText(lotterydata.get(position).game_name + ":结束");
                        getlottery(true, position);
                    }
                } catch (Exception e) {

                }
                holder.itemView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent intent = new Intent(getContext(), LotteryopenActivity.class);
                        intent.putExtra("gameid", lotterydata.get(position).gameId + "");
                        intent.putExtra("gamename", lotterydata.get(position).game_name);
                        startActivity(intent);
                    }
                });
            } else if (viewHolder instanceof MViewHolder3) {
                MViewHolder3 holder = (MViewHolder3) viewHolder;
                holder.resultname.setText(lotterydata.get(position).game_name + "");
                holder.resultdata.setText(lotterydata.get(position).preIssue + "期数");
                holder.resulttime.setText("");
                String[] strarray = new String[0];
                if (!TextUtils.isEmpty(lotterydata.get(position).preNum)) {
                    strarray = lotterydata.get(position).preNum.split(",");
                }
                if (strarray.length != 0) {
                    holder.pcdandan_one.setText(strarray[0]);
                    holder.pcdandan_two.setText(strarray[1]);
                    holder.pcdandan_three.setText(strarray[2]);

                    int a1 = Integer.parseInt(strarray[0]) + Integer.parseInt(strarray[1]) + Integer.parseInt(strarray[2]);
                    holder.pcdandan_fiv.setText(a1 + "");
                    holder.pcivtext_1.setText(a1 + "");
                    if (a1 > 13) {
                        holder.pcivtext_2.setText("大");
                    } else {
                        holder.pcivtext_2.setText("小");
                    }
                    if (a1 % 2 == 0) {
                        holder.pcivtext_3.setText("双");
                    } else {
                        holder.pcivtext_3.setText("单");
                    }
                }
                try {
                    long time = Timeutils.getStringToDate(lotterydata.get(position).lotteryTime) - Timeutils.getStringToDate(lotterydata.get(position).serverTime);
                    long timeStamp = System.currentTimeMillis() - mtemptime;
                    long finaltime = time - timeStamp;

//            将前一个缓存清除
                    if (holder.countDownTimer != null) {
                        holder.countDownTimer.cancel();
                    }
                    if (time > 0) {
                        holder.countDownTimer = new CountDownTimer(finaltime + 500, 1000) {
                            public void onTick(long millisUntilFinished) {
                                holder.resulttime.setText(String.valueOf(TimeTools.getCountTimeByLong(millisUntilFinished)));
                                if (String.valueOf(TimeTools.getCountTimeByLong(millisUntilFinished)).equals("00:00:00")) {
                                    holder.resulttime.setText("开奖中");
                                }
                            }

                            public void onFinish() {
                                holder.resulttime.setText("开奖中");
                                getlottery(true, position);
//                        holder.resulttime.setText(lotterydata.get(position).game_name + ":结束");
                            }
                        }.start();
                        countDownMap.put(holder.resulttime.hashCode(), holder.countDownTimer);
                    } else {
//                holder.resulttime.setText("00:00:00");
//                holder.resulttime.setText(lotterydata.get(position).game_name + ":结束");
                        getlottery(true, position);
                    }
                } catch (Exception e) {

                }
                holder.itemView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent intent = new Intent(getContext(), LotteryopenActivity.class);
                        intent.putExtra("gameid", lotterydata.get(position).gameId + "");
                        intent.putExtra("gamename", lotterydata.get(position).game_name);
                        startActivity(intent);
                    }
                });
            } else if (viewHolder instanceof MViewHolder4) {
                MViewHolder4 holder = (MViewHolder4) viewHolder;
                holder.resultname.setText(lotterydata.get(position).game_name + "");
                holder.resultdata.setText(lotterydata.get(position).preIssue + "期数");
                holder.resulttime.setText("");
                String[] strarray = new String[0];
                if (!TextUtils.isEmpty(lotterydata.get(position).preNum)) {
                    strarray = lotterydata.get(position).preNum.split(",");
                }
                holder.kuai8_six.setVisibility(View.VISIBLE);
                holder.kuai8_seven.setVisibility(View.VISIBLE);
                holder.kuai8_eight.setVisibility(View.VISIBLE);
                holder.kuai8shifenlin.setVisibility(View.GONE);
                holder.kuai8tv.setVisibility(View.VISIBLE);
                holder.kuai8_lin.setVisibility(View.VISIBLE);
                holder.kuai8_noon.setVisibility(View.VISIBLE);
                holder.kuai8_ten.setVisibility(View.VISIBLE);
                if (strarray.length != 0) {
                    holder.kuai8_one.setText(strarray[0]);
                    holder.kuai8_two.setText(strarray[1]);
                    holder.kuai8_three.setText(strarray[2]);
                    holder.kuai8_four.setText(strarray[3]);
                    holder.kuai8_fiv.setText(strarray[4]);
                    holder.kuai8_six.setText(strarray[5]);
                    holder.kuai8_seven.setText(strarray[6]);
                    holder.kuai8_eight.setText(strarray[7]);
                    holder.kuai8_noon.setText(strarray[8]);
                    holder.kuai8_ten.setText(strarray[9]);
                    holder.kuai8_1.setText(strarray[10]);
                    holder.kuai8_2.setText(strarray[11]);
                    holder.kuai8_3.setText(strarray[12]);
                    holder.kuai8_4.setText(strarray[13]);
                    holder.kuai8_5.setText(strarray[14]);
                    holder.kuai8_6.setText(strarray[15]);
                    holder.kuai8_7.setText(strarray[16]);
                    holder.kuai8_8.setText(strarray[17]);
                    holder.kuai8_9.setText(strarray[18]);
                    holder.kuai8_10.setText(strarray[19]);
                }
                try {
                    long time = Timeutils.getStringToDate(lotterydata.get(position).lotteryTime) - Timeutils.getStringToDate(lotterydata.get(position).serverTime);
                    long timeStamp = System.currentTimeMillis() - mtemptime;
                    long finaltime = time - timeStamp;

//            将前一个缓存清除
                    if (holder.countDownTimer != null) {
                        holder.countDownTimer.cancel();
                    }
                    if (time > 0) {
                        holder.countDownTimer = new CountDownTimer(finaltime + 500, 1000) {
                            public void onTick(long millisUntilFinished) {
                                holder.resulttime.setText(String.valueOf(TimeTools.getCountTimeByLong(millisUntilFinished)));
                                if (String.valueOf(TimeTools.getCountTimeByLong(millisUntilFinished)).equals("00:00:00")) {
                                    holder.resulttime.setText("开奖中");
                                }
                            }

                            public void onFinish() {
                                holder.resulttime.setText("开奖中");
                                getlottery(true, position);
//                        holder.resulttime.setText(lotterydata.get(position).game_name + ":结束");
                            }
                        }.start();
                        countDownMap.put(holder.resulttime.hashCode(), holder.countDownTimer);
                    } else {
//                holder.resulttime.setText("00:00:00");
//                holder.resulttime.setText(lotterydata.get(position).game_name + ":结束");
                        getlottery(true, position);
                    }
                } catch (Exception e) {

                }
                holder.itemView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent intent = new Intent(getContext(), LotteryopenActivity.class);
                        intent.putExtra("gameid", lotterydata.get(position).gameId + "");
                        intent.putExtra("gamename", lotterydata.get(position).game_name);
                        startActivity(intent);
                    }
                });
            } else if (viewHolder instanceof MViewHolder5) {
                MViewHolder5 holder = (MViewHolder5) viewHolder;
                holder.resultname.setText(lotterydata.get(position).game_name + "");
                holder.resultdata.setText(lotterydata.get(position).preIssue + "期数");
                holder.resulttime.setText("");
                String[] strarray = new String[0];
                if (!TextUtils.isEmpty(lotterydata.get(position).preNum)) {
                    strarray = lotterydata.get(position).preNum.split(",");
                }
                if (strarray.length != 0) {
                    holder.kuaisan_lin.setVisibility(View.VISIBLE);
                    holder.ivkuaisan1.setImageResource((blankiv[Integer.parseInt(strarray[0]) - 1]));
                    holder.ivkuaisan2.setImageResource((blankiv[Integer.parseInt(strarray[1]) - 1]));
                    holder.ivkuaisan3.setImageResource((blankiv[Integer.parseInt(strarray[2]) - 1]));
                    int b = Integer.parseInt(strarray[0]) + Integer.parseInt(strarray[1]) + Integer.parseInt(strarray[2]);
                    holder.kuaisan_1.setText(String.valueOf(b));
                    if (Integer.parseInt(strarray[0]) == Integer.parseInt(strarray[1]) && Integer.parseInt(strarray[0]) == Integer.parseInt(strarray[2])) {
                        holder.kuaisan_2.setText("豹子");
                    } else {
                        holder.kuaisan_2.setText(b >= 11 ? " 大 " : " 小 ");
                    }
                    holder.kuaisan_3.setText(b % 2 == 0 ? "双" : "单");
                } else {
                    holder.kuaisan_lin.setVisibility(View.GONE);
                }
                try {
                    long time = Timeutils.getStringToDate(lotterydata.get(position).lotteryTime) - Timeutils.getStringToDate(lotterydata.get(position).serverTime);
                    long timeStamp = System.currentTimeMillis() - mtemptime;
                    long finaltime = time - timeStamp;

//            将前一个缓存清除
                    if (holder.countDownTimer != null) {
                        holder.countDownTimer.cancel();
                    }
                    if (time > 0) {
                        holder.countDownTimer = new CountDownTimer(finaltime + 500, 1000) {
                            public void onTick(long millisUntilFinished) {
                                holder.resulttime.setText(String.valueOf(TimeTools.getCountTimeByLong(millisUntilFinished)));
                                if (String.valueOf(TimeTools.getCountTimeByLong(millisUntilFinished)).equals("00:00:00")) {
                                    holder.resulttime.setText("开奖中");
                                }
                            }

                            public void onFinish() {
                                holder.resulttime.setText("开奖中");
                                getlottery(true, position);
//                        holder.resulttime.setText(lotterydata.get(position).game_name + ":结束");
                            }
                        }.start();
                        countDownMap.put(holder.resulttime.hashCode(), holder.countDownTimer);
                    } else {
//                holder.resulttime.setText("00:00:00");
//                holder.resulttime.setText(lotterydata.get(position).game_name + ":结束");
                        getlottery(true, position);
                    }
                } catch (Exception e) {

                }
                holder.itemView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent intent = new Intent(getContext(), LotteryopenActivity.class);
                        intent.putExtra("gameid", lotterydata.get(position).gameId + "");
                        intent.putExtra("gamename", lotterydata.get(position).game_name);
                        startActivity(intent);
                    }
                });
            } else if (viewHolder instanceof MViewHolder6) {
                MViewHolder6 holder = (MViewHolder6) viewHolder;
                holder.resultname.setText(lotterydata.get(position).game_name + "");
                holder.resultdata.setText(lotterydata.get(position).preIssue + "期数");
                holder.resulttime.setText("");
                String[] strarray = new String[0];
                if (!TextUtils.isEmpty(lotterydata.get(position).preNum)) {
                    strarray = lotterydata.get(position).preNum.split(",");
                }
                holder.kuai8_six.setVisibility(View.VISIBLE);
                holder.kuai8_seven.setVisibility(View.VISIBLE);
                holder.kuai8_eight.setVisibility(View.VISIBLE);
                holder.kuai8shifenlin.setVisibility(View.VISIBLE);
                holder.kuai8tv.setVisibility(View.GONE);
                holder.kuai8_lin.setVisibility(View.VISIBLE);
                if (strarray.length != 0) {
                    holder.kuai8_one.setText(strarray[0]);
                    holder.kuai8_two.setText(strarray[1]);
                    holder.kuai8_three.setText(strarray[2]);
                    holder.kuai8_four.setText(strarray[3]);
                    holder.kuai8_fiv.setText(strarray[4]);
                    holder.kuai8_six.setText(strarray[5]);
                    holder.kuai8_seven.setText(strarray[6]);
                    holder.kuai8_eight.setText(strarray[7]);
                }

                holder.kuai8_noon.setVisibility(View.GONE);
                holder.kuai8_ten.setVisibility(View.GONE);
                int a1 = Integer.parseInt(strarray[0]) + Integer.parseInt(strarray[1]) + Integer.parseInt(strarray[2]) + Integer.parseInt(strarray[3]) +
                        Integer.parseInt(strarray[4]) + Integer.parseInt(strarray[5]) + Integer.parseInt(strarray[6]) + Integer.parseInt(strarray[7]);

                holder.shifentv1.setText(a1 + "");
                if (a1 > 84) {
                    holder.shifentv2.setText("大");
                } else if (a1 == 84) {
                    holder.shifentv2.setText("和");
                } else {
                    holder.shifentv2.setText("小");
                }
                holder.shifentv3.setText(a1 % 2 == 0 ? "双" : "单");
                holder.shifentv4.setText(a1 % 10 > 4 ? "大" : "小");
                holder.shifentv5.setVisibility(View.GONE);
                try {
                    long time = Timeutils.getStringToDate(lotterydata.get(position).lotteryTime) - Timeutils.getStringToDate(lotterydata.get(position).serverTime);
                    long timeStamp = System.currentTimeMillis() - mtemptime;
                    long finaltime = time - timeStamp;

//            将前一个缓存清除
                    if (holder.countDownTimer != null) {
                        holder.countDownTimer.cancel();
                    }
                    if (time > 0) {
                        holder.countDownTimer = new CountDownTimer(finaltime + 500, 1000) {
                            public void onTick(long millisUntilFinished) {
                                holder.resulttime.setText(String.valueOf(TimeTools.getCountTimeByLong(millisUntilFinished)));
                                if (String.valueOf(TimeTools.getCountTimeByLong(millisUntilFinished)).equals("00:00:00")) {
                                    holder.resulttime.setText("开奖中");
                                }
                            }

                            public void onFinish() {
                                holder.resulttime.setText("开奖中");
                                getlottery(true, position);
//                        holder.resulttime.setText(lotterydata.get(position).game_name + ":结束");
                            }
                        }.start();
                        countDownMap.put(holder.resulttime.hashCode(), holder.countDownTimer);
                    } else {
//                holder.resulttime.setText("00:00:00");
//                holder.resulttime.setText(lotterydata.get(position).game_name + ":结束");
                        getlottery(true, position);
                    }
                } catch (Exception e) {

                }
                holder.itemView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent intent = new Intent(getContext(), LotteryopenActivity.class);
                        intent.putExtra("gameid", lotterydata.get(position).gameId + "");
                        intent.putExtra("gamename", lotterydata.get(position).game_name);
                        startActivity(intent);
                    }
                });
            } else if (viewHolder instanceof MViewHolder7) {
                MViewHolder7 holder = (MViewHolder7) viewHolder;
                holder.resultname.setText(lotterydata.get(position).game_name + "");
                holder.resultdata.setText(lotterydata.get(position).preIssue + "期数");
                holder.resulttime.setText("");
                String[] strarray = new String[0];
                if (!TextUtils.isEmpty(lotterydata.get(position).preNum)) {
                    strarray = lotterydata.get(position).preNum.split(",");
                }
                holder.kuai8_six.setVisibility(View.VISIBLE);
                holder.kuai8_seven.setVisibility(View.VISIBLE);
                holder.kuai8_eight.setVisibility(View.VISIBLE);
                holder.kuai8shifenlin.setVisibility(View.VISIBLE);
                holder.kuai8tv.setVisibility(View.GONE);
                holder.kuai8_lin.setVisibility(View.VISIBLE);
                if (strarray.length != 0) {
                    holder.kuai8_one.setText(strarray[0]);
                    holder.kuai8_two.setText(strarray[1]);
                    holder.kuai8_three.setText(strarray[2]);
                    holder.kuai8_four.setText(strarray[3]);
                    holder.kuai8_fiv.setText(strarray[4]);
                    holder.kuai8_six.setText(strarray[5]);
                    holder.kuai8_seven.setText(strarray[6]);
                    holder.kuai8_eight.setText(strarray[7]);

                    int a = Integer.parseInt(strarray[0]) + Integer.parseInt(strarray[1]) + Integer.parseInt(strarray[2]) + Integer.parseInt(strarray[3]) +
                            Integer.parseInt(strarray[4]) + Integer.parseInt(strarray[5]) + Integer.parseInt(strarray[6]) + Integer.parseInt(strarray[7]);
                    holder.shifentv1.setText(a + "");
                    if (a > 84) {
                        holder.shifentv2.setText("大");
                    } else if (a == 84) {
                        holder.shifentv2.setText("和");
                    } else {
                        holder.shifentv2.setText("小");
                    }
                    holder.shifentv3.setText(a % 2 == 0 ? "双" : "单");
                    holder.shifentv4.setText(a % 10 > 5 ? "大" : "小");
                    holder.shifentv5.setVisibility(View.GONE);
                }

                holder.kuai8_noon.setVisibility(View.GONE);
                holder.kuai8_ten.setVisibility(View.GONE);
                try {
                    long time = Timeutils.getStringToDate(lotterydata.get(position).lotteryTime) - Timeutils.getStringToDate(lotterydata.get(position).serverTime);
                    long timeStamp = System.currentTimeMillis() - mtemptime;
                    long finaltime = time - timeStamp;

//            将前一个缓存清除
                    if (holder.countDownTimer != null) {
                        holder.countDownTimer.cancel();
                    }
                    if (time > 0) {
                        holder.countDownTimer = new CountDownTimer(finaltime + 500, 1000) {
                            public void onTick(long millisUntilFinished) {
                                holder.resulttime.setText(String.valueOf(TimeTools.getCountTimeByLong(millisUntilFinished)));
                                if (String.valueOf(TimeTools.getCountTimeByLong(millisUntilFinished)).equals("00:00:00")) {
                                    holder.resulttime.setText("开奖中");
                                }
                            }

                            public void onFinish() {
                                holder.resulttime.setText("开奖中");
                                getlottery(true, position);
//                        holder.resulttime.setText(lotterydata.get(position).game_name + ":结束");
                            }
                        }.start();
                        countDownMap.put(holder.resulttime.hashCode(), holder.countDownTimer);
                    } else {
//                holder.resulttime.setText("00:00:00");
//                holder.resulttime.setText(lotterydata.get(position).game_name + ":结束");
                        getlottery(true, position);
                    }
                } catch (Exception e) {

                }
                holder.itemView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent intent = new Intent(getContext(), LotteryopenActivity.class);
                        intent.putExtra("gameid", lotterydata.get(position).gameId + "");
                        intent.putExtra("gamename", lotterydata.get(position).game_name);
                        startActivity(intent);
                    }
                });
            } else if (viewHolder instanceof MViewHolder8) {
                MViewHolder8 holder = (MViewHolder8) viewHolder;
                holder.resultname.setText(lotterydata.get(position).game_name + "");
                holder.resultdata.setText(lotterydata.get(position).preIssue + "期数");
                holder.resulttime.setText("");
                String[] strarray = new String[0];
                if (!TextUtils.isEmpty(lotterydata.get(position).preNum)) {
                    strarray = lotterydata.get(position).preNum.split(",");
                }
                holder.kuai8shifenlin.setVisibility(View.VISIBLE);
                holder.kuai8tv.setVisibility(View.GONE);
                holder.kuai8_lin.setVisibility(View.VISIBLE);
                if (strarray.length != 0) {
                    holder.kuai8_one.setText(strarray[0]);
                    holder.kuai8_two.setText(strarray[1]);
                    holder.kuai8_three.setText(strarray[2]);
                    holder.kuai8_four.setText(strarray[3]);
                    holder.kuai8_fiv.setText(strarray[4]);
                    int a = Integer.parseInt(strarray[0]) + Integer.parseInt(strarray[1]) + Integer.parseInt(strarray[2]) + Integer.parseInt(strarray[3]) + Integer.parseInt(strarray[4]);
                    holder.shifentv1.setText(a + "");
                    if (a > 30) {
                        holder.shifentv2.setText("大");
                    } else if (a == 30) {
                        holder.shifentv2.setText("和");
                    } else {
                        holder.shifentv2.setText("小");
                    }
                    holder.shifentv3.setText(a % 2 == 0 ? "双" : "单");
                    holder.shifentv4.setText(a % 10 >= 5 ? "大" : "小");
                    holder.shifentv5.setVisibility(View.VISIBLE);
                    holder.shifentv5.setText(Integer.parseInt(strarray[0]) > Integer.parseInt(strarray[4]) ? "龙" : "虎");
                }
                holder.kuai8_six.setVisibility(View.GONE);
                holder.kuai8_seven.setVisibility(View.GONE);
                holder.kuai8_eight.setVisibility(View.GONE);
                holder.kuai8_noon.setVisibility(View.GONE);
                holder.kuai8_ten.setVisibility(View.GONE);
                try {
                    long time = Timeutils.getStringToDate(lotterydata.get(position).lotteryTime) - Timeutils.getStringToDate(lotterydata.get(position).serverTime);
                    long timeStamp = System.currentTimeMillis() - mtemptime;
                    long finaltime = time - timeStamp;

//            将前一个缓存清除
                    if (holder.countDownTimer != null) {
                        holder.countDownTimer.cancel();
                    }
                    if (time > 0) {
                        holder.countDownTimer = new CountDownTimer(finaltime + 500, 1000) {
                            public void onTick(long millisUntilFinished) {
                                holder.resulttime.setText(String.valueOf(TimeTools.getCountTimeByLong(millisUntilFinished)));
                                if (String.valueOf(TimeTools.getCountTimeByLong(millisUntilFinished)).equals("00:00:00")) {
                                    holder.resulttime.setText("开奖中");
                                }
                            }

                            public void onFinish() {
                                holder.resulttime.setText("开奖中");
                                getlottery(true, position);
//                        holder.resulttime.setText(lotterydata.get(position).game_name + ":结束");
                            }
                        }.start();
                        countDownMap.put(holder.resulttime.hashCode(), holder.countDownTimer);
                    } else {
//                holder.resulttime.setText("00:00:00");
//                holder.resulttime.setText(lotterydata.get(position).game_name + ":结束");
                        getlottery(true, position);
                    }
                } catch (Exception e) {

                }
                holder.itemView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent intent = new Intent(getContext(), LotteryopenActivity.class);
                        intent.putExtra("gameid", lotterydata.get(position).gameId + "");
                        intent.putExtra("gamename", lotterydata.get(position).game_name);
                        startActivity(intent);
                    }
                });
            } else if (viewHolder instanceof MViewHolder9) {
                MViewHolder9 holder = (MViewHolder9) viewHolder;
                holder.resultname.setText(lotterydata.get(position).game_name + "");
                holder.resultdata.setText(lotterydata.get(position).preIssue + "期数");
                holder.resulttime.setText("");
                String[] strarray = new String[0];
                if (!TextUtils.isEmpty(lotterydata.get(position).preNum)) {
                    strarray = lotterydata.get(position).preNum.split(",");
                }

                if (strarray.length != 0) {
                    holder.includ1_one1.setBackgroundResource(qiu[Liuhecaibose.toimg(strarray[0])]);
                    holder.includ1_one2.setBackgroundResource(qiu[Liuhecaibose.toimg(strarray[1])]);
                    holder.includ1_one3.setBackgroundResource(qiu[Liuhecaibose.toimg(strarray[2])]);
                    holder.includ1_one4.setBackgroundResource(qiu[Liuhecaibose.toimg(strarray[3])]);
                    holder.includ1_one5.setBackgroundResource(qiu[Liuhecaibose.toimg(strarray[4])]);
                    holder.includ1_one6.setBackgroundResource(qiu[Liuhecaibose.toimg(strarray[5])]);
                    holder.includ1_one8.setBackgroundResource(qiu[Liuhecaibose.toimg(strarray[6])]);

                    if (Integer.parseInt(strarray[0]) < 10 && Integer.parseInt(strarray[0]) != 0) {
                        holder.includ1_one1.setText("0" + strarray[0]);
                    } else {
                        holder.includ1_one1.setText(strarray[0]);
                    }
                    if (Integer.parseInt(strarray[1]) < 10 && Integer.parseInt(strarray[1]) != 0) {
                        holder.includ1_one2.setText("0" + strarray[1]);
                    } else {
                        holder.includ1_one2.setText(strarray[1]);
                    }
                    if (Integer.parseInt(strarray[2]) < 10 && Integer.parseInt(strarray[2]) != 0) {
                        holder.includ1_one3.setText("0" + strarray[2]);
                    } else {
                        holder.includ1_one3.setText(strarray[2]);
                    }
                    if (Integer.parseInt(strarray[3]) < 10 && Integer.parseInt(strarray[3]) != 0) {
                        holder.includ1_one4.setText("0" + strarray[3]);
                    } else {
                        holder.includ1_one4.setText(strarray[3]);
                    }
                    if (Integer.parseInt(strarray[4]) < 10 && Integer.parseInt(strarray[4]) != 0) {
                        holder.includ1_one5.setText("0" + strarray[4]);
                    } else {
                        holder.includ1_one5.setText(strarray[4]);
                    }
                    if (Integer.parseInt(strarray[5]) < 10 && Integer.parseInt(strarray[5]) != 0) {
                        holder.includ1_one6.setText("0" + strarray[5]);
                    } else {
                        holder.includ1_one6.setText(strarray[5]);
                    }
                    if (Integer.parseInt(strarray[6]) < 10 && Integer.parseInt(strarray[6]) != 0) {
                        holder.includ1_one8.setText("0" + strarray[6]);
                    } else {
                        holder.includ1_one8.setText(strarray[6]);
                    }
                    holder.includ1_one7.setVisibility(View.GONE);
                    holder.liuhecaitv1.setText(lotterydata.get(position).n1_sx);
                    holder.liuhecaitv2.setText(lotterydata.get(position).n2_sx);
                    holder.liuhecaitv3.setText(lotterydata.get(position).n3_sx);
                    holder.liuhecaitv4.setText(lotterydata.get(position).n4_sx);
                    holder.liuhecaitv5.setText(lotterydata.get(position).n5_sx);
                    holder.liuhecaitv6.setText(lotterydata.get(position).n6_sx);
                    holder.liuhecaitv7.setVisibility(View.GONE);
                    holder.liuhecaitv8.setText(lotterydata.get(position).n7_sx);
                }
                try {
                    long time = Timeutils.getStringToDate(lotterydata.get(position).lotteryTime) - Timeutils.getStringToDate(lotterydata.get(position).serverTime);
                    long timeStamp = System.currentTimeMillis() - mtemptime;
                    long finaltime = time - timeStamp;

//            将前一个缓存清除
                    if (holder.countDownTimer != null) {
                        holder.countDownTimer.cancel();
                    }
                    if (time > 0) {
                        holder.countDownTimer = new CountDownTimer(finaltime + 500, 1000) {
                            public void onTick(long millisUntilFinished) {
                                holder.resulttime.setText(String.valueOf(TimeTools.getCountTimeByLong(millisUntilFinished)));
                                if (String.valueOf(TimeTools.getCountTimeByLong(millisUntilFinished)).equals("00:00:00")) {
                                    holder.resulttime.setText("开奖中");
                                }
                            }

                            public void onFinish() {
                                holder.resulttime.setText("开奖中");
                                getlottery(true, position);
//                        holder.resulttime.setText(lotterydata.get(position).game_name + ":结束");
                            }
                        }.start();
                        countDownMap.put(holder.resulttime.hashCode(), holder.countDownTimer);
                    } else {
//                holder.resulttime.setText("00:00:00");
//                holder.resulttime.setText(lotterydata.get(position).game_name + ":结束");
                        getlottery(true, position);
                    }
                } catch (Exception e) {

                }

                holder.itemView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent intent = new Intent(getContext(), LotteryopenActivity.class);
                        intent.putExtra("gameid", lotterydata.get(position).gameId + "");
                        intent.putExtra("gamename", lotterydata.get(position).game_name);
                        startActivity(intent);
                    }
                });
            }
        }

        @Override
        public int getItemCount() {
            return lotterydata.size();
        }

        @Override
        public void onItemClick(View view, int position) {

        }

        class MViewHolder extends RecyclerView.ViewHolder {
            public CountDownTimer countDownTimer;
            TextView resultdata;
            TextView resultname;
            TextView resulttime;
            ImageView includ1_one, includ1_two, includ1_three, includ1_four, includ1_five, includ1_six, includ1_seven, includ1_eight, includ1_noon, includ1_ten;
            TextView ivtext_1, ivtext_2, ivtext_3, ivtext_4, ivtext_5, ivtext_6, ivtext_7, ivtext_8;

            MViewHolder(View itemView) {
                super(itemView);
                resultdata = (TextView) itemView.findViewById(R.id.resultdata);//期数
                resultname = (TextView) itemView.findViewById(R.id.resultname);//名称
                resulttime = (TextView) itemView.findViewById(R.id.resulttime);//倒计时
                includ1_one = (ImageView) itemView.findViewById(R.id.includ1_one);
                includ1_two = (ImageView) itemView.findViewById(R.id.includ1_two);
                includ1_three = (ImageView) itemView.findViewById(R.id.includ1_three);
                includ1_four = (ImageView) itemView.findViewById(R.id.includ1_four);
                includ1_five = (ImageView) itemView.findViewById(R.id.includ1_five);
                includ1_six = (ImageView) itemView.findViewById(R.id.includ1_six);
                includ1_seven = (ImageView) itemView.findViewById(R.id.includ1_seven);
                includ1_eight = (ImageView) itemView.findViewById(R.id.includ1_eight);
                includ1_noon = (ImageView) itemView.findViewById(R.id.includ1_noon);
                includ1_ten = (ImageView) itemView.findViewById(R.id.includ1_ten);
                ivtext_1 = (TextView) itemView.findViewById(R.id.ivtext_1);
                ivtext_2 = (TextView) itemView.findViewById(R.id.ivtext_2);
                ivtext_3 = (TextView) itemView.findViewById(R.id.ivtext_3);
                ivtext_4 = (TextView) itemView.findViewById(R.id.ivtext_4);
                ivtext_5 = (TextView) itemView.findViewById(R.id.ivtext_5);
                ivtext_6 = (TextView) itemView.findViewById(R.id.ivtext_6);
                ivtext_7 = (TextView) itemView.findViewById(R.id.ivtext_7);
                ivtext_8 = (TextView) itemView.findViewById(R.id.ivtext_8);
            }
        }

        class MViewHolder1 extends RecyclerView.ViewHolder {
            public CountDownTimer countDownTimer;
            TextView resultdata;
            TextView resultname;
            TextView resulttime;
            ImageView includ1_one, includ1_two, includ1_three, includ1_four, includ1_five, includ1_six, includ1_seven, includ1_eight, includ1_noon, includ1_ten;
            TextView ivtext_1, ivtext_2, ivtext_3, ivtext_4, ivtext_5, ivtext_6, ivtext_7, ivtext_8;

            MViewHolder1(View itemView) {
                super(itemView);
                resultdata = (TextView) itemView.findViewById(R.id.resultdata);//期数
                resultname = (TextView) itemView.findViewById(R.id.resultname);//名称
                resulttime = (TextView) itemView.findViewById(R.id.resulttime);//倒计时
                includ1_one = (ImageView) itemView.findViewById(R.id.includ1_one);
                includ1_two = (ImageView) itemView.findViewById(R.id.includ1_two);
                includ1_three = (ImageView) itemView.findViewById(R.id.includ1_three);
                includ1_four = (ImageView) itemView.findViewById(R.id.includ1_four);
                includ1_five = (ImageView) itemView.findViewById(R.id.includ1_five);
                includ1_six = (ImageView) itemView.findViewById(R.id.includ1_six);
                includ1_seven = (ImageView) itemView.findViewById(R.id.includ1_seven);
                includ1_eight = (ImageView) itemView.findViewById(R.id.includ1_eight);
                includ1_noon = (ImageView) itemView.findViewById(R.id.includ1_noon);
                includ1_ten = (ImageView) itemView.findViewById(R.id.includ1_ten);
                ivtext_1 = (TextView) itemView.findViewById(R.id.ivtext_1);
                ivtext_2 = (TextView) itemView.findViewById(R.id.ivtext_2);
                ivtext_3 = (TextView) itemView.findViewById(R.id.ivtext_3);
                ivtext_4 = (TextView) itemView.findViewById(R.id.ivtext_4);
                ivtext_5 = (TextView) itemView.findViewById(R.id.ivtext_5);
                ivtext_6 = (TextView) itemView.findViewById(R.id.ivtext_6);
                ivtext_7 = (TextView) itemView.findViewById(R.id.ivtext_7);
                ivtext_8 = (TextView) itemView.findViewById(R.id.ivtext_8);
            }
        }

        class MViewHolder2 extends RecyclerView.ViewHolder {
            public CountDownTimer countDownTimer;
            TextView resultdata;
            TextView resultname;
            TextView resulttime;
            TextView kuai8_onet, kuai8_twot, kuai8_threet, kuai8_fourt, kuai8_fivt, kuai8_sixt, kuai8_sevent, kuai8_eightt, kuai8_noont, kuai8_tent;
            ImageView niu1, niu2, niu3, niu4, niu5, niu6;
            LinearLayout xian1, xian2, xian3, xian4, xian5, zhuanglin;

            MViewHolder2(View itemView) {
                super(itemView);
                resultdata = (TextView) itemView.findViewById(R.id.resultdata);//期数
                resultname = (TextView) itemView.findViewById(R.id.resultname);//名称
                resulttime = (TextView) itemView.findViewById(R.id.resulttime);//倒计时
                kuai8_onet = (TextView) itemView.findViewById(R.id.kuai8_onet);
                kuai8_twot = (TextView) itemView.findViewById(R.id.kuai8_twot);
                kuai8_threet = (TextView) itemView.findViewById(R.id.kuai8_threet);
                kuai8_fourt = (TextView) itemView.findViewById(R.id.kuai8_fourt);
                kuai8_fivt = (TextView) itemView.findViewById(R.id.kuai8_fivt);
                kuai8_sixt = (TextView) itemView.findViewById(R.id.kuai8_sixt);
                kuai8_sevent = (TextView) itemView.findViewById(R.id.kuai8_sevent);
                kuai8_eightt = (TextView) itemView.findViewById(R.id.kuai8_eightt);
                kuai8_noont = (TextView) itemView.findViewById(R.id.kuai8_noont);
                kuai8_tent = (TextView) itemView.findViewById(R.id.kuai8_tent);
                niu1 = (ImageView) itemView.findViewById(R.id.niu1);
                niu2 = (ImageView) itemView.findViewById(R.id.niu2);
                niu3 = (ImageView) itemView.findViewById(R.id.niu3);
                niu4 = (ImageView) itemView.findViewById(R.id.niu4);
                niu5 = (ImageView) itemView.findViewById(R.id.niu5);
                niu6 = (ImageView) itemView.findViewById(R.id.niu6);
                xian1 = (LinearLayout) itemView.findViewById(R.id.xian1);
                xian2 = (LinearLayout) itemView.findViewById(R.id.xian2);
                xian3 = (LinearLayout) itemView.findViewById(R.id.xian3);
                xian4 = (LinearLayout) itemView.findViewById(R.id.xian4);
                xian5 = (LinearLayout) itemView.findViewById(R.id.xian5);
                zhuanglin = (LinearLayout) itemView.findViewById(R.id.zhuanglin);
            }
        }

        class MViewHolder3 extends RecyclerView.ViewHolder {
            public CountDownTimer countDownTimer;
            TextView resultdata;
            TextView resultname;
            TextView resulttime;
            TextView pcdandan_one, pcdandan_two, pcdandan_three, pcdandan_four, pcdandan_fiv, pcivtext_1, pcivtext_2, pcivtext_3;

            MViewHolder3(View itemView) {
                super(itemView);
                resultdata = (TextView) itemView.findViewById(R.id.resultdata);//期数
                resultname = (TextView) itemView.findViewById(R.id.resultname);//名称
                resulttime = (TextView) itemView.findViewById(R.id.resulttime);//倒计时
                pcdandan_one = (TextView) itemView.findViewById(R.id.pcdandan_one);
                pcdandan_two = (TextView) itemView.findViewById(R.id.pcdandan_two);
                pcdandan_three = (TextView) itemView.findViewById(R.id.pcdandan_three);
                pcdandan_four = (TextView) itemView.findViewById(R.id.pcdandan_four);
                pcdandan_fiv = (TextView) itemView.findViewById(R.id.pcdandan_fiv);
                pcivtext_1 = (TextView) itemView.findViewById(R.id.pcivtext_1);
                pcivtext_2 = (TextView) itemView.findViewById(R.id.pcivtext_2);
                pcivtext_3 = (TextView) itemView.findViewById(R.id.pcivtext_3);
            }
        }

        class MViewHolder4 extends RecyclerView.ViewHolder {
            public CountDownTimer countDownTimer;
            TextView resultdata;
            TextView resultname;
            TextView resulttime;
            TextView kuai8_1, kuai8_2, kuai8_3, kuai8_4, kuai8_5, kuai8_6, kuai8_7, kuai8_8, kuai8_9, kuai8_10;
            TextView kuai8_one, kuai8_two, kuai8_three, kuai8_four, kuai8_fiv, kuai8_six, kuai8_seven, kuai8_eight, kuai8_noon, kuai8_ten;
            LinearLayout kuai8shifenlin, kuai8tv, kuai8_lin;

            MViewHolder4(View itemView) {
                super(itemView);
                resultdata = (TextView) itemView.findViewById(R.id.resultdata);//期数
                resultname = (TextView) itemView.findViewById(R.id.resultname);//名称
                resulttime = (TextView) itemView.findViewById(R.id.resulttime);//倒计时
                kuai8_1 = (TextView) itemView.findViewById(R.id.kuai8_1);
                kuai8_2 = (TextView) itemView.findViewById(R.id.kuai8_2);
                kuai8_3 = (TextView) itemView.findViewById(R.id.kuai8_3);
                kuai8_4 = (TextView) itemView.findViewById(R.id.kuai8_4);
                kuai8_5 = (TextView) itemView.findViewById(R.id.kuai8_5);
                kuai8_6 = (TextView) itemView.findViewById(R.id.kuai8_6);
                kuai8_7 = (TextView) itemView.findViewById(R.id.kuai8_7);
                kuai8_8 = (TextView) itemView.findViewById(R.id.kuai8_8);
                kuai8_9 = (TextView) itemView.findViewById(R.id.kuai8_9);
                kuai8_10 = (TextView) itemView.findViewById(R.id.kuai8_10);
                kuai8_one = (TextView) itemView.findViewById(R.id.kuai8_one);
                kuai8_two = (TextView) itemView.findViewById(R.id.kuai8_two);
                kuai8_three = (TextView) itemView.findViewById(R.id.kuai8_three);
                kuai8_four = (TextView) itemView.findViewById(R.id.kuai8_four);
                kuai8_fiv = (TextView) itemView.findViewById(R.id.kuai8_fiv);
                kuai8_six = (TextView) itemView.findViewById(R.id.kuai8_six);
                kuai8_seven = (TextView) itemView.findViewById(R.id.kuai8_seven);
                kuai8_eight = (TextView) itemView.findViewById(R.id.kuai8_eight);
                kuai8_noon = (TextView) itemView.findViewById(R.id.kuai8_noon);
                kuai8_ten = (TextView) itemView.findViewById(R.id.kuai8_ten);
                kuai8shifenlin = (LinearLayout) itemView.findViewById(R.id.kuai8shifenlin);//快乐十分时隐藏
                kuai8tv = (LinearLayout) itemView.findViewById(R.id.kuai8tv);//快乐十分时隐藏
                kuai8_lin = (LinearLayout) itemView.findViewById(R.id.kuai8_lin);
            }
        }

        class MViewHolder5 extends RecyclerView.ViewHolder {
            public CountDownTimer countDownTimer;
            TextView resultdata;
            TextView resultname;
            TextView resulttime;
            ImageView ivkuaisan1, ivkuaisan2, ivkuaisan3;
            TextView kuaisan_1, kuaisan_2, kuaisan_3;
            LinearLayout kuaisan_lin;

            MViewHolder5(View itemView) {
                super(itemView);
                resultdata = (TextView) itemView.findViewById(R.id.resultdata);//期数
                resultname = (TextView) itemView.findViewById(R.id.resultname);//名称
                resulttime = (TextView) itemView.findViewById(R.id.resulttime);//倒计时
                ivkuaisan1 = (ImageView) itemView.findViewById(R.id.ivkuaisan1);
                ivkuaisan2 = (ImageView) itemView.findViewById(R.id.ivkuaisan2);
                ivkuaisan3 = (ImageView) itemView.findViewById(R.id.ivkuaisan3);
                kuaisan_1 = (TextView) itemView.findViewById(R.id.kuaisan_1);
                kuaisan_2 = (TextView) itemView.findViewById(R.id.kuaisan_2);
                kuaisan_3 = (TextView) itemView.findViewById(R.id.kuaisan_3);
                kuaisan_lin = (LinearLayout) itemView.findViewById(R.id.kuaisan_lin);
            }
        }

        class MViewHolder6 extends RecyclerView.ViewHolder {
            public CountDownTimer countDownTimer;
            TextView resultdata;
            TextView resultname;
            TextView resulttime;
            LinearLayout kuai8shifenlin, kuai8tv, kuai8_lin;
            TextView kuai8_1, kuai8_2, kuai8_3, kuai8_4, kuai8_5, kuai8_6, kuai8_7, kuai8_8, kuai8_9, kuai8_10;
            TextView kuai8_one, kuai8_two, kuai8_three, kuai8_four, kuai8_fiv, kuai8_six, kuai8_seven, kuai8_eight, kuai8_noon, kuai8_ten;
            TextView shifentv1, shifentv2, shifentv3, shifentv4, shifentv5;

            MViewHolder6(View itemView) {
                super(itemView);
                resultdata = (TextView) itemView.findViewById(R.id.resultdata);//期数
                resultname = (TextView) itemView.findViewById(R.id.resultname);//名称
                resulttime = (TextView) itemView.findViewById(R.id.resulttime);//倒计时
                kuai8_1 = (TextView) itemView.findViewById(R.id.kuai8_1);
                kuai8_2 = (TextView) itemView.findViewById(R.id.kuai8_2);
                kuai8_3 = (TextView) itemView.findViewById(R.id.kuai8_3);
                kuai8_4 = (TextView) itemView.findViewById(R.id.kuai8_4);
                kuai8_5 = (TextView) itemView.findViewById(R.id.kuai8_5);
                kuai8_6 = (TextView) itemView.findViewById(R.id.kuai8_6);
                kuai8_7 = (TextView) itemView.findViewById(R.id.kuai8_7);
                kuai8_8 = (TextView) itemView.findViewById(R.id.kuai8_8);
                kuai8_9 = (TextView) itemView.findViewById(R.id.kuai8_9);
                kuai8_10 = (TextView) itemView.findViewById(R.id.kuai8_10);
                kuai8_one = (TextView) itemView.findViewById(R.id.kuai8_one);
                kuai8_two = (TextView) itemView.findViewById(R.id.kuai8_two);
                kuai8_three = (TextView) itemView.findViewById(R.id.kuai8_three);
                kuai8_four = (TextView) itemView.findViewById(R.id.kuai8_four);
                kuai8_fiv = (TextView) itemView.findViewById(R.id.kuai8_fiv);
                kuai8_six = (TextView) itemView.findViewById(R.id.kuai8_six);
                kuai8_seven = (TextView) itemView.findViewById(R.id.kuai8_seven);
                kuai8_eight = (TextView) itemView.findViewById(R.id.kuai8_eight);
                kuai8_noon = (TextView) itemView.findViewById(R.id.kuai8_noon);
                kuai8_ten = (TextView) itemView.findViewById(R.id.kuai8_ten);
                shifentv1 = (TextView) itemView.findViewById(R.id.shifentv1);
                shifentv2 = (TextView) itemView.findViewById(R.id.shifentv2);
                shifentv3 = (TextView) itemView.findViewById(R.id.shifentv3);
                shifentv4 = (TextView) itemView.findViewById(R.id.shifentv4);
                shifentv5 = (TextView) itemView.findViewById(R.id.shifentv5);
                kuai8shifenlin = (LinearLayout) itemView.findViewById(R.id.kuai8shifenlin);//快乐十分时隐藏
                kuai8tv = (LinearLayout) itemView.findViewById(R.id.kuai8tv);//快乐十分时隐藏
                kuai8_lin = (LinearLayout) itemView.findViewById(R.id.kuai8_lin);
            }
        }

        class MViewHolder7 extends RecyclerView.ViewHolder {
            public CountDownTimer countDownTimer;
            TextView resultdata;
            TextView resultname;
            TextView resulttime;
            LinearLayout kuai8shifenlin, kuai8tv, kuai8_lin;
            TextView kuai8_1, kuai8_2, kuai8_3, kuai8_4, kuai8_5, kuai8_6, kuai8_7, kuai8_8, kuai8_9, kuai8_10;
            TextView kuai8_one, kuai8_two, kuai8_three, kuai8_four, kuai8_fiv, kuai8_six, kuai8_seven, kuai8_eight, kuai8_noon, kuai8_ten;
            TextView shifentv1, shifentv2, shifentv3, shifentv4, shifentv5;

            MViewHolder7(View itemView) {
                super(itemView);
                resultdata = (TextView) itemView.findViewById(R.id.resultdata);//期数
                resultname = (TextView) itemView.findViewById(R.id.resultname);//名称
                resulttime = (TextView) itemView.findViewById(R.id.resulttime);//倒计时
                kuai8_1 = (TextView) itemView.findViewById(R.id.kuai8_1);
                kuai8_2 = (TextView) itemView.findViewById(R.id.kuai8_2);
                kuai8_3 = (TextView) itemView.findViewById(R.id.kuai8_3);
                kuai8_4 = (TextView) itemView.findViewById(R.id.kuai8_4);
                kuai8_5 = (TextView) itemView.findViewById(R.id.kuai8_5);
                kuai8_6 = (TextView) itemView.findViewById(R.id.kuai8_6);
                kuai8_7 = (TextView) itemView.findViewById(R.id.kuai8_7);
                kuai8_8 = (TextView) itemView.findViewById(R.id.kuai8_8);
                kuai8_9 = (TextView) itemView.findViewById(R.id.kuai8_9);
                kuai8_10 = (TextView) itemView.findViewById(R.id.kuai8_10);
                kuai8_one = (TextView) itemView.findViewById(R.id.kuai8_one);
                kuai8_two = (TextView) itemView.findViewById(R.id.kuai8_two);
                kuai8_three = (TextView) itemView.findViewById(R.id.kuai8_three);
                kuai8_four = (TextView) itemView.findViewById(R.id.kuai8_four);
                kuai8_fiv = (TextView) itemView.findViewById(R.id.kuai8_fiv);
                kuai8_six = (TextView) itemView.findViewById(R.id.kuai8_six);
                kuai8_seven = (TextView) itemView.findViewById(R.id.kuai8_seven);
                kuai8_eight = (TextView) itemView.findViewById(R.id.kuai8_eight);
                kuai8_noon = (TextView) itemView.findViewById(R.id.kuai8_noon);
                kuai8_ten = (TextView) itemView.findViewById(R.id.kuai8_ten);
                shifentv1 = (TextView) itemView.findViewById(R.id.shifentv1);
                shifentv2 = (TextView) itemView.findViewById(R.id.shifentv2);
                shifentv3 = (TextView) itemView.findViewById(R.id.shifentv3);
                shifentv4 = (TextView) itemView.findViewById(R.id.shifentv4);
                shifentv5 = (TextView) itemView.findViewById(R.id.shifentv5);
                kuai8shifenlin = (LinearLayout) itemView.findViewById(R.id.kuai8shifenlin);//快乐十分时隐藏
                kuai8tv = (LinearLayout) itemView.findViewById(R.id.kuai8tv);//快乐十分时隐藏
                kuai8_lin = (LinearLayout) itemView.findViewById(R.id.kuai8_lin);
            }
        }

        class MViewHolder8 extends RecyclerView.ViewHolder {
            public CountDownTimer countDownTimer;
            TextView resultdata;
            TextView resultname;
            TextView resulttime;
            TextView kuai8_1, kuai8_2, kuai8_3, kuai8_4, kuai8_5, kuai8_6, kuai8_7, kuai8_8, kuai8_9, kuai8_10;
            TextView kuai8_one, kuai8_two, kuai8_three, kuai8_four, kuai8_fiv, kuai8_six, kuai8_seven, kuai8_eight, kuai8_noon, kuai8_ten;
            TextView shifentv1, shifentv2, shifentv3, shifentv4, shifentv5;
            LinearLayout kuai8shifenlin, kuai8tv, kuai8_lin;

            MViewHolder8(View itemView) {
                super(itemView);
                resultdata = (TextView) itemView.findViewById(R.id.resultdata);//期数
                resultname = (TextView) itemView.findViewById(R.id.resultname);//名称
                resulttime = (TextView) itemView.findViewById(R.id.resulttime);//倒计时
                kuai8_1 = (TextView) itemView.findViewById(R.id.kuai8_1);
                kuai8_2 = (TextView) itemView.findViewById(R.id.kuai8_2);
                kuai8_3 = (TextView) itemView.findViewById(R.id.kuai8_3);
                kuai8_4 = (TextView) itemView.findViewById(R.id.kuai8_4);
                kuai8_5 = (TextView) itemView.findViewById(R.id.kuai8_5);
                kuai8_6 = (TextView) itemView.findViewById(R.id.kuai8_6);
                kuai8_7 = (TextView) itemView.findViewById(R.id.kuai8_7);
                kuai8_8 = (TextView) itemView.findViewById(R.id.kuai8_8);
                kuai8_9 = (TextView) itemView.findViewById(R.id.kuai8_9);
                kuai8_10 = (TextView) itemView.findViewById(R.id.kuai8_10);
                kuai8_one = (TextView) itemView.findViewById(R.id.kuai8_one);
                kuai8_two = (TextView) itemView.findViewById(R.id.kuai8_two);
                kuai8_three = (TextView) itemView.findViewById(R.id.kuai8_three);
                kuai8_four = (TextView) itemView.findViewById(R.id.kuai8_four);
                kuai8_fiv = (TextView) itemView.findViewById(R.id.kuai8_fiv);
                kuai8_six = (TextView) itemView.findViewById(R.id.kuai8_six);
                kuai8_seven = (TextView) itemView.findViewById(R.id.kuai8_seven);
                kuai8_eight = (TextView) itemView.findViewById(R.id.kuai8_eight);
                kuai8_noon = (TextView) itemView.findViewById(R.id.kuai8_noon);
                kuai8_ten = (TextView) itemView.findViewById(R.id.kuai8_ten);
                shifentv1 = (TextView) itemView.findViewById(R.id.shifentv1);
                shifentv2 = (TextView) itemView.findViewById(R.id.shifentv2);
                shifentv3 = (TextView) itemView.findViewById(R.id.shifentv3);
                shifentv4 = (TextView) itemView.findViewById(R.id.shifentv4);
                shifentv5 = (TextView) itemView.findViewById(R.id.shifentv5);
                kuai8shifenlin = (LinearLayout) itemView.findViewById(R.id.kuai8shifenlin);//快乐十分时隐藏
                kuai8tv = (LinearLayout) itemView.findViewById(R.id.kuai8tv);//快乐十分时隐藏
                kuai8_lin = (LinearLayout) itemView.findViewById(R.id.kuai8_lin);
            }
        }

        class MViewHolder9 extends RecyclerView.ViewHolder {
            public CountDownTimer countDownTimer;
            TextView resultdata;
            TextView resultname;
            TextView resulttime;
            TextView includ1_one1, includ1_one2, includ1_one3, includ1_one4, includ1_one5, includ1_one6, includ1_one7, includ1_one8;
            TextView liuhecaitv1, liuhecaitv2, liuhecaitv3, liuhecaitv4, liuhecaitv5, liuhecaitv6, liuhecaitv7, liuhecaitv8;

            MViewHolder9(View itemView) {
                super(itemView);
                resultdata = (TextView) itemView.findViewById(R.id.resultdata);//期数
                resultname = (TextView) itemView.findViewById(R.id.resultname);//名称
                resulttime = (TextView) itemView.findViewById(R.id.resulttime);//倒计时
                includ1_one1 = (TextView) itemView.findViewById(R.id.includ1_one1);
                includ1_one2 = (TextView) itemView.findViewById(R.id.includ1_one2);
                includ1_one3 = (TextView) itemView.findViewById(R.id.includ1_one3);
                includ1_one4 = (TextView) itemView.findViewById(R.id.includ1_one4);
                includ1_one5 = (TextView) itemView.findViewById(R.id.includ1_one5);
                includ1_one6 = (TextView) itemView.findViewById(R.id.includ1_one6);
                includ1_one7 = (TextView) itemView.findViewById(R.id.includ1_one7);
                includ1_one8 = (TextView) itemView.findViewById(R.id.includ1_one8);
                includ1_one8 = (TextView) itemView.findViewById(R.id.includ1_one8);
                liuhecaitv1 = (TextView) itemView.findViewById(R.id.liuhecaitv1);
                liuhecaitv2 = (TextView) itemView.findViewById(R.id.liuhecaitv2);
                liuhecaitv3 = (TextView) itemView.findViewById(R.id.liuhecaitv3);
                liuhecaitv4 = (TextView) itemView.findViewById(R.id.liuhecaitv4);
                liuhecaitv5 = (TextView) itemView.findViewById(R.id.liuhecaitv5);
                liuhecaitv6 = (TextView) itemView.findViewById(R.id.liuhecaitv6);
                liuhecaitv7 = (TextView) itemView.findViewById(R.id.liuhecaitv7);
                liuhecaitv8 = (TextView) itemView.findViewById(R.id.liuhecaitv8);
            }
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        adapter.cancelAllTimers();
    }


    //大厅开奖
    public void getlottery(final boolean isrefreshItem, final int position) {
        if (isrefreshItem) {
            //当更新单个数据的时候，我们延迟3秒开奖，以保证获取到最新的数据
            new Thread(new Runnable() {
                @Override
                public void run() {
                    SystemClock.sleep(2000);
                    HttpJsonUtils.getHttpApiInstance()
                            .getlottery1(HttpAdress.getuseAdress() + "api/m/lottery/getNextIssue.do", Info.user.token)
                            .subscribeOn(Schedulers.io())
                            .observeOn(AndroidSchedulers.mainThread())
                            .subscribe(new CustomObserver<ResLottery1>() {
                                @Override
                                protected void onCustomNext(ResLottery1 resLottery) {
                                    if (resLottery.code == 0 && resLottery.data != null) {
                                        adapter.setGetTime(System.currentTimeMillis());
                                        lotterydata.clear();
                                        //这里我们添加存在的彩种
                                        for (int i = 0; i < resLottery.data.size(); i++) {
                                            if (resLottery.data.get(i).gameId == 80 || resLottery.data.get(i).gameId== 50 ||
                                                    resLottery.data.get(i).gameId == 82 || resLottery.data.get(i).gameId == 99 ||
                                                    resLottery.data.get(i).gameId == 81 || resLottery.data.get(i).gameId == 1 ||
                                                    resLottery.data.get(i).gameId == 4  || resLottery.data.get(i).gameId == 91 ||
                                                    resLottery.data.get(i).gameId == 90 || resLottery.data.get(i).gameId == 66 ||
                                                    resLottery.data.get(i).gameId == 65 || resLottery.data.get(i).gameId == 86 ||
                                                    resLottery.data.get(i).gameId == 10 || resLottery.data.get(i).gameId == 12 ||
                                                    resLottery.data.get(i).gameId == 13 || resLottery.data.get(i).gameId == 16 ||
                                                    resLottery.data.get(i).gameId == 15 || resLottery.data.get(i).gameId == 18 ||
                                                    resLottery.data.get(i).gameId == 11 || resLottery.data.get(i).gameId == 60 ||
                                                    resLottery.data.get(i).gameId == 61 || resLottery.data.get(i).gameId == 21 ||
                                                    resLottery.data.get(i).gameId == 70 || resLottery.data.get(i).gameId == 85 ||
                                                    resLottery.data.get(i).gameId == 113 || resLottery.data.get(i).gameId == 801
                                                    || resLottery.data.get(i).gameId == 802 || resLottery.data.get(i).gameId == 803
                                                    || resLottery.data.get(i).gameId == 804 || resLottery.data.get(i).gameId == 901
                                                    || resLottery.data.get(i).gameId == 902 || resLottery.data.get(i).gameId == 903
                                                    || resLottery.data.get(i).gameId == 904 || resLottery.data.get(i).gameId == 55
                                                    ) {
                                                lotterydata.add(resLottery.data.get(i));
                                            }
                                        }
                                        if (isrefreshItem) {
                                            adapter.notifyItemChanged(position);
                                        }
                                        map.clear();
                                        for (int i = 0; i < lotterydata.size(); i++) {

                                            if (!TextUtils.isEmpty(lotterydata.get(i).gameOfficeUrl + "")) {
//                                    SYSOUtils.sOut_("+++++++++++++++++++++++++++++++++++++++" + lotterydata.get(i).gameOfficeUrl);
                                                map.put(lotterydata.get(i).gameId + "", lotterydata.get(i).gameOfficeUrl + "");
                                            }
                                        }
                                        Info.offurl = map;
                                    }
                                }

                                @Override
                                protected void onSubscribeCustom(Disposable disposable) {
                                }

                                @Override
                                protected void onErrorCustom(Throwable e) {

                                }
                            });
                }
            }).start();
        } else {

            HttpJsonUtils.getHttpApiInstance()
                    .getlottery1(HttpAdress.getuseAdress() + "api/m/lottery/getNextIssue.do", Info.user.token)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribe(new CustomObserver<ResLottery1>() {
                        @Override
                        protected void onCustomNext(ResLottery1 resLottery) {
                            if (resLottery.code == 0 && resLottery.data != null) {
                                adapter.setGetTime(System.currentTimeMillis());
                                lotterydata.clear();
                                for (int i = 0; i < resLottery.data.size(); i++) {
                                    if (resLottery.data.get(i).gameId == 80 || resLottery.data.get(i).gameId== 50 ||
                                            resLottery.data.get(i).gameId == 82 || resLottery.data.get(i).gameId == 99 ||
                                            resLottery.data.get(i).gameId == 81 || resLottery.data.get(i).gameId == 1 ||
                                            resLottery.data.get(i).gameId == 4  || resLottery.data.get(i).gameId == 91 ||
                                            resLottery.data.get(i).gameId == 90 || resLottery.data.get(i).gameId == 66 ||
                                            resLottery.data.get(i).gameId == 65 || resLottery.data.get(i).gameId == 86 ||
                                            resLottery.data.get(i).gameId == 10 || resLottery.data.get(i).gameId == 12 ||
                                            resLottery.data.get(i).gameId == 13 || resLottery.data.get(i).gameId == 16 ||
                                            resLottery.data.get(i).gameId == 15 || resLottery.data.get(i).gameId == 18 ||
                                            resLottery.data.get(i).gameId == 11 || resLottery.data.get(i).gameId == 60 ||
                                            resLottery.data.get(i).gameId == 61 || resLottery.data.get(i).gameId == 21 ||
                                            resLottery.data.get(i).gameId == 70 || resLottery.data.get(i).gameId == 85 ||
                                            resLottery.data.get(i).gameId == 113 || resLottery.data.get(i).gameId == 801
                                            || resLottery.data.get(i).gameId == 802 || resLottery.data.get(i).gameId == 803
                                            || resLottery.data.get(i).gameId == 804 || resLottery.data.get(i).gameId == 901
                                            || resLottery.data.get(i).gameId == 902 || resLottery.data.get(i).gameId == 903
                                            || resLottery.data.get(i).gameId == 904 || resLottery.data.get(i).gameId == 55
                                            ) {
                                        lotterydata.add(resLottery.data.get(i));
                                    }
                                }
                                adapter.notifyDataSetChanged();
                                map.clear();
                                for (int i = 0; i < lotterydata.size(); i++) {

                                    if (!TextUtils.isEmpty(lotterydata.get(i).gameOfficeUrl + "")) {
//                                    SYSOUtils.sOut_("+++++++++++++++++++++++++++++++++++++++" + lotterydata.get(i).gameOfficeUrl);
                                        map.put(lotterydata.get(i).gameId + "", lotterydata.get(i).gameOfficeUrl + "");
                                    }
                                }
                                Info.offurl = map;
                            }
                        }

                        @Override
                        protected void onSubscribeCustom(Disposable disposable) {
                        }

                        @Override
                        protected void onErrorCustom(Throwable e) {

                        }
                    });
        }
    }
}
